home *** CD-ROM | disk | FTP | other *** search
/ PC World Interactive 7 / PC World Interactive 7.iso / program / asprog.EXE / DRIVES.ASM < prev    next >
Assembly Source File  |  1996-06-26  |  6KB  |  165 lines

  1. ; Drive detection by: Lee Hamel (hamell@cs.pdx.edu) - July 6th, 1994
  2. ; Partial credit to : Paul Schlyter
  3. ;
  4. ; Goes thru drives A-Z and determines if they:
  5. ; 1) Exist
  6. ; 2) Are removable or fixed
  7. ; 3) Are local, remote, or shared
  8. ; 4) Are a floppy, hard, RAM, subst, or CD-ROM drive
  9.  
  10. .model tiny
  11. .286
  12.  
  13. DRIVEXISTS      EQU     1
  14.  
  15. REMOVEDRV       EQU     0
  16. FIXEDDRV        EQU     1
  17.  
  18. LOCALDRV        EQU     0
  19. REMOTEDRV       EQU     1
  20. SHAREDRV        EQU     2
  21.  
  22. FLOPPY          EQU     0
  23. HARD            EQU     1
  24. RAM             EQU     2
  25. SUBST           EQU     3
  26. CDROM           EQU     4
  27.  
  28. .code
  29.         org     100h
  30.  
  31. start:          mov     ah,19h
  32.                 int     21h             ; get start drive
  33.                 mov     [curdrive],al
  34.  
  35.                 mov     ax,40h
  36.                 mov     es,ax
  37.                 mov     bh,es:[10h]     ; 40:10h is # of floppies-1
  38.                 shr     bh,6
  39.                 inc     bh              ; # of actual floppy drives
  40.                 mov     bl,1
  41.                 mov     di,offset drives
  42. nextchkfloppy:  mov     ax,4409h        ; check if drive exists
  43.                 int     21h
  44.                 jc      nextsetfloppy
  45.                 test    dh,10000000b    ; check if SUBST drive
  46.                 jz      chkfloppy
  47.                 dec     bh              ; dec actual drive count
  48.                 mov     byte ptr [di+3],SUBST
  49. setfloppyexist: mov     byte ptr [di],DRIVEXISTS
  50.                 jmp     nextsetfloppy
  51. chkfloppy:      dec     bh              ; dec actual drive count
  52.                 js      nextsetfloppy
  53.                 mov     byte ptr [di+1],REMOVEDRV
  54.                 mov     byte ptr [di+3],FLOPPY
  55.                 jmp     setfloppyexist
  56. nextsetfloppy:  add     di,4
  57.                 inc     bl
  58.                 cmp     bl,2            ; if B then jump back
  59.                 je      nextchkfloppy
  60.  
  61.                 mov     ch,24           ; loop 24 times (drives C - Z)
  62.                 mov     cl,3            ; start at C:
  63. drivechkloop:   mov     ax,4409h        ; check if drive exists
  64.                 mov     bl,cl           ; set drive letter
  65.                 int     21h             ; 0 = default, 1 = A:, etc.
  66.                 jc      nextsetdrv
  67.                 mov     byte ptr [di],DRIVEXISTS
  68.                 mov     ax,4408h        ; check if removable
  69.                 int     21h
  70.                 mov     byte ptr [di+1],al      ; set REMOVABLE or FIXED
  71.                 mov     bx,dx
  72.                 mov     dl,dh
  73.                 shr     dl,7
  74.                 and     dh,00010000b
  75.                 shr     dh,4
  76.                 mov     byte ptr [di+2],dh      ; set REMOTE or LOCAL
  77.                 or      dl,dl                   ; if not SUBST, then jump
  78.                 jz      chkremote
  79.                 mov     byte ptr [di+3],SUBST
  80.                 jmp     nextsetdrv
  81.  
  82. chkremote:      cmp     dh,REMOTEDRV    ; if REMOTE, then check for CD ROM
  83.                 je      chkcdrom
  84.  
  85.                 test    bh,00000010b    ; sharable?
  86.                 jz      drivenoshare
  87.                 mov     byte ptr [di+2],SHAREDRV
  88. drivenoshare:   test    bl,00000010b    ; RAM drive?
  89.                 jnz     nextsetdrv
  90.                 mov     byte ptr [di+3],RAM
  91.                 jmp     nextsetdrv
  92.  
  93. chkcdrom:       push    cx
  94.                 mov     ax,1500h
  95.                 xor     bx,bx
  96.                 int     2fh
  97.                 pop     cx
  98.                 or      bx,bx           ; MSCDEX driver found?
  99.                 jz      nextsetdrv      ; if not, jump to next drive setup
  100.                 mov     ax,150bh
  101.                 dec     cl              ; 0=A:, etc.
  102.                 int     2fh
  103.                 inc     cl
  104.                 or      ax,ax
  105.                 jz      nextsetdrv      ; drive supported by MSCDEX?
  106.                 mov     byte ptr [di+3],CDROM
  107.  
  108. nextsetdrv:     add     di,4
  109.                 inc     cl
  110.                 dec     ch
  111.                 jnz     drivechkloop
  112.  
  113.                 mov     ah,0eh
  114.                 mov     dl,[curdrive]
  115.                 int     21h             ; reset start drive
  116.  
  117.                 mov     cl,'A'          ; output all existing drives
  118.                 mov     di,offset drives
  119.                 mov     ah,9
  120. drvdumploop:    cmp     byte ptr [di],DRIVEXISTS
  121.                 jne     nextdrvdump
  122.                 mov     al,cl
  123.                 int     29h
  124.                 xor     dh,dh
  125.                 mov     dl,byte ptr [di+1]
  126.                 shl     dx,4
  127.                 add     dx,offset removablemsg
  128.                 int     21h
  129.                 xor     dh,dh
  130.                 mov     dl,byte ptr [di+2]
  131.                 shl     dx,3
  132.                 add     dx,offset localmsg
  133.                 int     21h
  134.                 xor     dh,dh
  135.                 mov     dl,byte ptr [di+3]
  136.                 shl     dx,3
  137.                 add     dx,offset typemsg
  138.                 int     21h
  139.                 mov     dx,offset crlf
  140.                 int     21h
  141.  
  142. nextdrvdump:    add     di,4
  143.                 inc     cl
  144.                 cmp     cl,'Z'
  145.                 jbe     drvdumploop
  146.  
  147.                 ret
  148.  
  149. curdrive        db      0
  150. drives          db      26 dup(0,1,0,1)
  151.         ; default to not exist, fixed, local, hard drive
  152. crlf            db      10,13,'$'
  153. removablemsg    db      ':    Removable $'
  154.                 db      ':        Fixed $'
  155. localmsg        db      'Local  $'
  156.                 db      'Remote $'
  157.                 db      'Shared $'
  158. typemsg         db      'Floppy $'
  159.                 db      'Hard   $'
  160.                 db      'RAM    $'
  161.                 db      'Subst  $'
  162.                 db      'CD-ROM $'
  163.  
  164.         end     start
  165.